<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
    <style>
        .layui-table th {
            font-size: 16px;
            font-weight: 600;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <input type="hidden" id="operateType" value="${operateType}">
            <table class="layui-hide" id="reportingTable" lay-filter="reportingTables"></table>
<%--            <table lay-filter="inventoryTables" class="layui-table" lay-data="{url:'<%=request.getContextPath()%>/rest/reporting/subtotal',defaultToolbar: ['filter','print'], cellMinWidth: 80, page: false, toolbar: '#subtotalExports', height: 'full-100',totalRow:true}">--%>
<%--                <thead>--%>
<%--                <tr>--%>
<%--                    <th lay-data="{align:'center'}" colspan="7">物资分类汇总表</th>--%>
<%--                </tr>--%>
<%--                <tr>--%>
<%--                    <th lay-data="{align:'right'}" colspan="7">统计区间：${year}年01月-${year}年11月</th>--%>
<%--                </tr>--%>
<%--                <tr>--%>
<%--                    <th lay-data="{field:'number',align: 'center',width:'4%'}">序号</th>--%>
<%--                    <th lay-data="{field:'category',align: 'center',width:'16.2%',totalRowText: '合计'}" >类别名称</th>--%>
<%--                    <th lay-data="{field:'allCount',align: 'center',width:'16%',totalRow: true}">物资总数</th>--%>
<%--                    <th lay-data="{field:'inCount',align: 'center',width:'16%',totalRow: true}">在库数量</th>--%>
<%--                    <th lay-data="{field:'outCount',align: 'center',width:'16%',totalRow: true}">出库数量</th>--%>
<%--                    <th lay-data="{field:'maintainCount',align: 'center',width:'16%',totalRow: true}">维保数量</th>--%>
<%--                    <th lay-data="{field:'scrapCount',align: 'center',width:'16%',totalRow: true}">报废数量</th>--%>
<%--                </tr>--%>
<%--                </thead>--%>
<%--            </table>--%>
            <div style="padding-top: 5px;"> <div style="text-align: right" > 制表人：${user.name}<input type="text"  style="visibility:hidden;width:20px;"> 制表时间：${datetime}&nbsp;</div></div>
        </div>
    </div>
</div>
<%--<script type="text/html" id="subtotalExports">--%>
<%--    <div class="layui-inline" lay-event="exports" title="导出">--%>
<%--        <i class="layui-icon layui-icon-export"></i>--%>
<%--    </div>--%>
<%--</script>--%>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script>
    layui.use(['table','layer'], function(){
        var $ = layui.$
            , table = layui.table
            , layer = layui.layer;
        var operateType = $("#operateType").val();
        var title = "";
        var data = null;
        switch (operateType) {
            case "alert":title = "设备故障汇总表";
            data = [{field: 'sort', title: '序号', sort: true}
                , {field: 'type', title: '故障类型', sort: true}
                , {field: 'sum', title: '故障次数汇总', sort: true}];
            break;
            case "lined":title = "乡镇村委会的设备统计表";
                data = [{field: 'sort', title: '序号', sort: true}
                    , {field: 'zhen', title: '乡镇', sort: true}
                    , {field: 'cunweihui', title: '村委会', sort: true}
                    , {field: 'sum', title: '设备数量', sort: true}
                    , {field: 'video', title: '监控数量', sort: true}];
                break;
            case "water":title = "水质检测情况汇总表";
                data = [{field: 'sort', title: '序号', sort: true}
                    , {field: 'cunname', title: '村名', sort: true}
                    , {field: 'sum', title: '检测次数', sort: true}];break;
            case "peasant":title = "乡镇村委会登记农户统计";
                data = [{field: 'sort', title: '序号', sort: true}
                    , {field: 'zhen', title: '乡镇', sort: true}
                    , {field: 'cunweihui', title: '村委会', sort: true}
                    , {field: 'sum', title: '农户数量', sort: true}];break;
            default:break;
        }
        table.render({
            elem: '#reportingTable'
            , url: "<%=request.getContextPath()%>/rest/base/getReportingData"
            , title:title
            , height:'full-193'
            , page: false
            , text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
            , toolbar: '#reportingOperation'
            , defaultToolbar: ['filter',{
                title: '导出' //标题
                ,layEvent: 'exportdatas' //事件名，用于 toolbar 事件中使用
                ,icon: 'layui-icon-export' //图标类名
            },'print']
            , cols: [data]
            , where: {
                operateType:operateType,
            }
            , done: function (res, curr, count) {
                if(res.errorMsg==null){

                }else {
                    layer.msg(res.errorMsg);
                }
                $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
                var curnum = $("#curnum").val();
            }
        });
        //监听头工具栏事件
        table.on('toolbar(reportingTables)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id)
                ,data = checkStatus.data;//获取选中的数据
            switch(obj.event){
                case 'exportdatas':
                    exports();
                    break;
            }
        });

        function exports(){
            var url="<%=request.getContextPath()%>/rest/base/importReportingExcel?operateType=" + operateType;
            window.open(url);
        }
    });
</script>
</body>
</html>